#include "texturemanager.h"



TextureManager::TextureManager() : ids(), tex()
{

}

TextureManager::~TextureManager()
{
    std::vector<FTexture *>::iterator ptr(tex.begin());
    for(; ptr!=tex.end() ; ptr++)
        if(*ptr)
            delete *ptr;
}

FTexture * TextureManager::addTexture(const std::string &fileName)
{
    std::vector<std::string>::iterator ptr(ids.begin());
    unsigned int n(0);
    bool find(false);
    for(; (n < ids.size()) && !find ; n++ )
    {
        if( fileName == *ptr)
            find = true;
        ptr++;
    }

    if( find )
        return tex[n-1];
    else
    {
        FTexture * tmp = new FTexture((char *)fileName.data());
        ids.push_back(fileName);
        tex.push_back(tmp);
        return tmp;
    }
}
